'''
    Tutor user's methods
'''
#-*- coding: UTF-8 -*- 

import MySQLdb
import types
from WeiboUser import WeiboUser
from conf import *
from MySqlDBHandle import MySqlDBHandle

class TutorUser:        
    mWeiboId=1
    mName=""
    mGender=''
    def InsertTutorsToDB(self):
#        self.mWeiboId = -1
#        self.mName = "Liu, Huan"
#        self.mGender = 'm'
#        self._insertUserToDB()
        
        self.mWeiboId = 1719232542
        self.mName = "Na, Ying"
        self.mGender = 'f'
        self._insertUserToDB()
        
        self.mWeiboId = 1838993640
        self.mName = "Yu, Chengqin"
        self.mGender = 'm'
        self._insertUserToDB()
        
        self.mWeiboId = 1276314124
        self.mName = "Yang Kun"
        self.mGender = 'm'
        self._insertUserToDB()
        
    def _insertUserToDB(self):
        if self._IsUserIdInDB():
            return
        else:
            try:
                lSQLStatement = "INSERT INTO LU_tutor (Tutor_name, Weibo_id, genderID, LAST_UPDATE_TIMESTAMP) VALUES (%s, %s, %s, current_timestamp);" \
                % (self.mName, self.mWeiboId, self.mGender )
                MySqlDBHandle.execSqlStatement(lSQLStatement)
            except Exception, e:
                print "Error in TutorUser.py InsertTutorToDB function with " + str(e)
                
    def _IsUserIdInDB(self):
        lSQLStatement = "SELECT * FROM lu_tutor WHERE Weibo_id = %s;" % self.mWeiboId
        result = MySqlDBHandle.execSqlStatement(lSQLStatement)
        if result is None:
            return False
        else:
            return True
    

    
